import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
import path from "path"
import tailwindcss from "tailwindcss";
import autoprefixer from "autoprefixer";
import VitePluginVueDevTools from "vite-plugin-vue-devtools";
import externalGlobals from "rollup-plugin-external-globals";

// https://vitejs.dev/config/
export default defineConfig({
    envPrefix: "APP_",
    build: {
        rollupOptions: {
            plugins: [
                externalGlobals({
                    "vue": "Vue",
                    "vue-router": "VueRouter",
                    "axios": "axios",
                    "naive-ui": "naive"
                })
            ]
        }
    },
    resolve: {
        alias: {
            "@": path.resolve(__dirname, "src"),
        }
    },
    server: {
        host: "0.0.0.0",
        proxy: {
            "/api": {
                target: "http://127.0.0.1:8080",
                changeOrigin: true
            },
            "/ws": {
                target: "ws://127.0.0.1:8080",
                changeOrigin: true,
                ws: true
            }
        }
    },
    plugins: [
        vue()
    ],
    css: {
        postcss: {
            plugins: [tailwindcss, autoprefixer]
        }
    }
})
